#ifndef __SJA1000_H
#define __SJA1000_H

/*clock divider register*/
#define SJA1000_CD        (0   & 0x07)
#define SJA1000_CLKOFF		(0   & 0x01)
#define SJA1000_RXINTEN		(0   & 0x01)
#define SJA1000_CBP       (1 	 & 0x01)
#define SJA1000_CANMODE		(1   & 0x01)	//0:Basic CAN mode , 1:Peli CAN mode

/*bus timing register*/
#define SJA1000_BRP       (4   & 0x3f)
#define SJA1000_SJW       (3	 & 0x03)
#define SJA1000_TSEG1	    (4	 & 0x0f)
#define SJA1000_TSEG2     (3	 & 0x07)
#define SJA1000_SAM       (0	 & 0x01)
/* Baud Rate = fCLK / ((BRP+1) * 2 * (TSEG1 + TSEG2 + 3)) 
             = 50MHz / (5 * 2 * (5 + 4 + 1)) = 500KHz*/

/*output control*/
#define SJA1000_OCMODE    (2	 & 0x03)
#define SJA1000_OCPOL0    (0	 & 0x01)
#define SJA1000_OCTN0     (1	 & 0x01)
#define SJA1000_OCTP0     (1	 & 0x01)
#define SJA1000_OCPOL1    (0	 & 0x01)
#define SJA1000_OCTN1     (0	 & 0x01)
#define SJA1000_OCTP1     (0	 & 0x01)

/*acceptance code*/
#define SJA1000_ACPCODE   0x00000000

/*acceptance mask*/
#define SJA1000_ACPMASK		0xffffffff

typedef struct CAN_PACKAGE
{
  unsigned char format;   //frame format 0:SFF 1:EFF
  unsigned char RTR;      //remote transmission request
  unsigned char DLC;      //data length code
  unsigned long ID;
  unsigned char data[8];
} CAN_PACKAGE;

#endif
